<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML5 Worker</title>

    <script>
        myWorker = new Worker("worker.js");
        myWorker.postMessage(10); // 向 Worker 发送数据
        myWorker.onmessage = (event) => {  // <===>  myWorker.addEventListener('message', e => {})
            console.log(event.data);
        };
    </script>
</head>

<body>
    <h1>HTML5 Worker</h1>
</body>

</html>